﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ServiceLayer.Forms
{
    using HelpSystem;

    public partial class FormTransport : Form
    {
        public String GovNumber
        {
            get
            {
                return tbGovNumber.Text;
            }
            set
            {
                if (value.Length > 10)
                    tbGovNumber.Text = value;
                else
                    tbGovNumber.Text = value.Substring(0, 10);
                this.Text = tbGovNumber.Text;
            }
        }

        public String TransportType
        {
            get
            {
                return cbTransportType.Text;
            }
            set
            {
                if (!cbTransportType.Items.Contains(value))
                    Documentation.ShowError("Ошибка присвоения. Данный тип странспорта не содержится в базе данных.");
                cbTransportType.Text = value;
            }
        }

        public String[] TransportTypeList
        {
            get
            {
                String[] List = new String[cbTransportType.Items.Count];
                cbTransportType.Items.CopyTo(List, 0);
                return List;
            }
            set
            {
                cbTransportType.Items.Clear();
                cbTransportType.Items.AddRange(value);
            }
        }

        public DateTime DateTO
        {
            get
            {
                return dtDateTO.Value;
            }
            set
            {
                dtDateTO.Value = value;
            }
        }

        public String VIN
        {
            get
            {
                return tbVIN.Text;
            }
            set
            {
                if (value.Length > 20)
                    tbVIN.Text = value.Substring(0, 20);
                else
                    tbVIN.Text = value;
            }
        }

        public FormTransport(String[] TransportTypeList)
        {
            InitializeComponent();
            this.TransportTypeList = TransportTypeList;
        }

        private void FormTransport_Load(object sender, EventArgs e)
        {

        }

        private void miClose_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
